package com.wyl.xue.admin.system.mybatis.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wyl.xue.admin.system.mybatis.entity.SystemDepartment;
import com.wyl.xue.admin.system.mybatis.mapper.SystemDepartmentMapper;
import com.wyl.xue.admin.system.mybatis.service.SystemDepartmentService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


/**
 * @ClassName: SystemDepartmentServiceImpl
 * @Function: 部门
 * @Date: 2019/12/18 22:11
 * @author wyl
 * @version V1.0
 */
@Service
@Slf4j
@AllArgsConstructor
@DS("master")
public class SystemDepartmentServiceImpl extends ServiceImpl<SystemDepartmentMapper, SystemDepartment> implements SystemDepartmentService {

    /**
     * @Description 部门是否有子节点
     * @param departmentId
     * @return java.lang.Boolean
     * @Date 2020/11/21 22:36
     * @Author wangyl
     * @Version V1.0
     */
    @Override
    public Boolean hasChildDepartment(long departmentId) {
        LambdaQueryWrapper<SystemDepartment> systemMenuLambdaQueryWrapper = Wrappers.lambdaQuery(SystemDepartment.class)
                                                                                    .eq(SystemDepartment::getParentId, departmentId)
                                                                                    .last("limit 1");
        return !list(systemMenuLambdaQueryWrapper).isEmpty();
    }
}
